/*
* I18NUtil.java
* Created on  202015-01-21 0021 13:47
* 版本       修改时间          作者      修改内容
* V1.0.1    2015-01-21       gaoxinyu    初始版本
*
*/
package com.wonderland.sail.util;

import org.springframework.web.servlet.i18n.SessionLocaleResolver;

import javax.servlet.http.HttpSession;
import java.util.Locale;
import java.util.ResourceBundle;

/**
 * @author gaoxinyu
 * @version 1.0.1
 */
public class SailI18NUtil {
    public static String getSailResourceBundleString(HttpSession session, String msgString) {
        return getResourceBundleString(session,"SailViewMessages",msgString);
    }

    public static String getResourceBundleString(HttpSession session, String baseName, String msgString) {
        Object obj = session.getAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME);
        Locale locale = new Locale("en");
        if (obj != null) {
            locale = (Locale) obj;
        }
        return ResourceBundle.getBundle(baseName, locale).getString(msgString);
    }

}
